<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php');
if (!is_numeric($_GET['ID'])) {MsgBox (1,'ID参数出现非数字错误！','-1');}
$nUser = $db->SelectSQL("SELECT `UserName`,`UserPassword`,`UserProtectionQuestion`,`UserProtectionAnswer`,
				   `UserTrueName`,`UserSex`,`UserEmail`,`UserCompany`,`UserWeb`,`UserAddress`,`UserTel`,
				   `UserFax`,`UserLevel`,`UserAudit` FROM `" . $dbprefix . "user` WHERE `ID` = '" . $_GET['ID'] . "'");
if(count($nUser)==0){MsgBox (1,'不存在的会员！','-1');}
Html($nUser[0]);

if($_POST['Action']=='UpDate'){
	$UserPassword = $nUser[0][1] == $_POST['UserPassword'] ?  $_POST['UserPassword'] : md5($_POST['UserPassword']);
	$nUserLevel = is_numeric($_POST['nUserLevel']) ? $_POST['nUserLevel'] : 0;
	$SQL = "UPDATE `" . $dbprefix . "user` SET 
	`UserPassword` = '" . $UserPassword . "',
	`UserProtectionQuestion` = '" . $_POST['UserProtectionQuestion'] . "',
	`UserProtectionAnswer` = '" . $_POST['UserProtectionAnswer'] . "',
	`UserTrueName` = '" . $_POST['UserTrueName'] . "',
	`UserSex` = '" . $_POST['UserSex'] . "',
	`UserEmail` = '" . $_POST['UserEmail'] . "',
	`UserCompany` = '" . $_POST['UserCompany'] . "',
	`UserWeb` = '" . $_POST['UserWeb'] . "',
	`UserAddress` = '" . $_POST['UserAddress'] . "',
	`UserTel` = '" . $_POST['UserTel'] . "',
	`UserFax` = '" . $_POST['UserFax'] . "',
	`UserLevel` = '" . $nUserLevel . "',
	`UserAudit` = '" . $_POST['UserAudit'] . "' WHERE `ID` = '" . $_GET['ID'] . "' LIMIT 1; ";
	if($db->ExecuteSQL($SQL)){
		AdminLog(1,$Lang,'修改会员资料(' . $nUser[0][0] . ')，结果：操作成功！'); 
		MsgBox (1,'会员修改成功！','UsersManage.php');
	} else {
		AdminLog(1,$Lang,'修改会员资料(' .  $nUser[0][0] . ')，结果：操作失败！'); 
		MsgBox (1,'操作失败，请检查您提交的数据是否正确！','-1');
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script language="javascript">
function Check() {
	if (document.form1.UserPassword.value.length<5){
		alert("密码必须为5-20个字符！");
		document.form1.UserPassword.focus();
		return false;
	}	
	if (document.form1.UserPassword.value!=document.form1.UserPassword2.value){
		alert("两次输入的密码不一致！");
		document.form1.UserPassword2.focus();
		return false;
	}	
	if (document.form1.UserProtectionQuestion.value.length<4){
		alert("密码保护问题必须大于4个字符！");
		document.form1.UserProtectionQuestion.focus();
		return false;
	}
	if (document.form1.UserProtectionAnswer.value.length<4){
		alert("密码保护答案必须大于4个字符！");
		document.form1.UserProtectionAnswer.focus();
		return false;
	}
	if (document.form1.UserEmail.value.length<4){
		alert("请输入正确的E-Mail！");
		document.form1.UserEmail.focus();
		return false;
	}	
	if (document.form1.UserTel.value==""){
		alert("请输入联系电话！");
		document.form1.UserTel.focus();
		return false;
	}	
}
</script>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd">
	<td>&nbsp;</td>
	<td align="right">
		<input type="button" value="添加会员" onClick="javascript:location.href='UsersAdd.php?Lang=<?php echo $Lang?>'">
		<input type="button" value="会员管理" onClick="javascript:location.href='UsersManage.php?Lang=<?php echo $Lang?>'">		
		<input type="button" value="权限管理" onClick="javascript:location.href='UsersPermissions.php?Lang=<?php echo $Lang?>'">
	</td>
	</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td colspan="3" align="center" class="Main_Title">修改会员资料</td>
  </tr>
  <form name="form1" method="post" action="UsersUpDate.php?ID=<?php echo $_GET['ID']?>" onSubmit="return Check()">
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">用 户 名：</td>
      <td height="30" align="left" bgcolor="#FFFFFF"><input name="UserName" type="text" disabled="disabled" class="input2" id="UserName" value="<?php echo $nUser[0][0]?>" size="20" maxlength="14" readonly="readonly" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF" class="ippv">登录用户名不可以修改</td>
    </tr>
    
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">密　　码：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserPassword" type="password" class="input2" id="UserPassword" size="20" maxlength="16" value="<?php echo $nUser[0][1]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF" class="ippv">由5-20个字符组成</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">确认密码：</td>
      <td height="30" align="left" bgcolor="#FFFFFF"><input name="UserPassword2" type="password" class="input2" id="UserPassword2" size="20" maxlength="16" value="<?php echo $nUser[0][1]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">密码问题：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserProtectionQuestion" type="text" class="input2" id="UserProtectionQuestion" size="20" maxlength="20" value="<?php echo $nUser[0][2]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">问题答案：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserProtectionAnswer" type="text" class="input2" id="UserProtectionAnswer" size="20" maxlength="20" value="<?php echo $nUser[0][3]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">真实姓名：</td>
      <td height="30" align="left" bgcolor="#FFFFFF"><input name="UserTrueName" type="text" class="input_200_17" id="UserTrueName" size="20" maxlength="20" value="<?php echo $nUser[0][4]?>" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">性　　别：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserSex" type="radio" value="1" <?php if($nUser[0][5]==1) echo 'checked="checked"';?> />
        男&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="radio" name="UserSex" value="0" <?php if($nUser[0][5]==0) echo 'checked="checked"';?> />
        女</td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">E－mail：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserEmail" type="text" class="input2" id="UserEmail" size="20" maxlength="50" value="<?php echo $nUser[0][6]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">公司名称：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserCompany" type="text" class="input2" id="UserCompany" size="20" maxlength="50" value="<?php echo $nUser[0][7]?>" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">网　　址：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserWeb" type="text" class="input2" id="UserWeb" size="20" maxlength="50" value="<?php echo $nUser[0][8]?>" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">地　　址：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserAddress" type="text" class="input2" id="UserAddress" size="20" maxlength="50" value="<?php echo $nUser[0][9]?>" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">联系电话：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserTel" type="text" class="input_200_17" id="UserTel" size="20" maxlength="20" value="<?php echo $nUser[0][10]?>" />
        <font color="#FF0000">*</font></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">传　　真：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserFax" type="text" class="input_200_17" id="UserFax" size="20" maxlength="20" value="<?php echo $nUser[0][11]?>" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <!--tr class="odd">
    	<td align="right" bgcolor="#FFFFFF">会员级别：</td>
    	<td align="left" bgcolor="#FFFFFF">
		<select name="nUserLevel" id="nUserLevel">
<?php
foreach ($UserLevel as $i => $value){
	if($nUser[0][12]!=$value[1])
		echo '<option value="' . $value[1] . '">' . $value[0] . '</option>' . "\n";
	else
		echo '<option selected="selected" value="' . $value[1] . '">' . $value[0] . '</option>' . "\n";
}
?>		
	</select></td>
    	<td align="left" bgcolor="#FFFFFF" class="ippv">&nbsp;</td>
    	</tr-->
    <tr class="odd">
      <td align="right" bgcolor="#FFFFFF">审核状态：</td>
      <td align="left" bgcolor="#FFFFFF"><input name="UserAudit" type="radio" id="radio" value="1" <?php if($nUser[0][13]==1) echo 'checked="checked"';?> />
        通过审核
        <input type="radio" name="UserAudit" id="radio2" value="0"  <?php if($nUser[0][13]==0) echo 'checked="checked"';?> />
        取消审核</td>
      <td align="left" bgcolor="#FFFFFF" class="ippv">未通过审核的会员将被拒绝登录</td>
    </tr>
    <tr class="odd">
      <td align="center" bgcolor="#FFFFFF">&nbsp;</td>
      <td align="left" bgcolor="#FFFFFF"><input name="Submit" type="submit" value="修 改" class="submit" />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="Submit2" type="reset" value="重 置" class="submit" />
        <input name="Action" type="hidden" id="Action" value="UpDate" /></td>
      <td align="left" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  </form>
</table>
</body>
</html>
